<template>
  <div class="bilibili-not-found">
    <!-- 背景装饰元素 -->
    <div class="decoration-elements">
      <div class="floating-element element-1">🚀</div>
      <div class="floating-element element-2">📺</div>
      <div class="floating-element element-3">🎮</div>
      <div class="floating-element element-4">❤️</div>
    </div>

    <!-- 主要内容区域 -->
    <div class="not-found-container">
      <!-- 错误代码和动画 -->
      <div class="error-animation">
        <div class="error-number">4</div>
        <div class="error-illustration">
          <div class="broken-tv">
            <div class="tv-screen">
              <div class="static-effect"></div>
            </div>
            <div class="tv-stand"></div>
          </div>
        </div>
        <div class="error-number">4</div>
      </div>

      <!-- 错误信息 -->
      <div class="error-content">
        <h1 class="error-title">页面迷路了</h1>
        <p class="error-description">
          抱歉，您访问的页面不存在或已被移至其他地方[1,2](@ref)
        </p>

        <!-- 可能的原因 -->
        <div class="possible-reasons">
          <h3>可能的原因：</h3>
          <ul>
            <li>网址输入错误</li>
            <li>页面已被删除或移动</li>
            <li>暂时性的技术问题</li>
          </ul>
        </div>

        <!-- 操作按钮 -->
        <div class="action-buttons">
          <el-button
              type="primary"
              size="large"
              @click="goHome"
              class="primary-btn"
          >
            <el-icon><HomeFilled /></el-icon>
            返回首页
          </el-button>

          <el-button
              type="default"
              size="large"
              @click="goBack"
              class="secondary-btn"
          >
            <el-icon><ArrowLeft /></el-icon>
            返回上页
          </el-button>

          <el-button
              type="success"
              size="large"
              @click="refreshPage"
              class="refresh-btn"
          >
            <el-icon><Refresh /></el-icon>
            刷新页面
          </el-button>
        </div>

        <!-- 快速导航 -->
        <div class="quick-nav">
          <h3>快速导航：</h3>
          <div class="nav-links">
            <router-link to="/" class="nav-link">
              <el-icon><House /></el-icon>
              首页
            </router-link>
            <router-link to="/hot" class="nav-link">
              <el-icon><Fire /></el-icon>
              热门
            </router-link>
            <router-link to="/dynamic" class="nav-link">
              <el-icon><Promotion /></el-icon>
              动态
            </router-link>
            <router-link to="/channel" class="nav-link">
              <el-icon><Menu /></el-icon>
              频道
            </router-link>
          </div>
        </div>

        <!-- 搜索框 -->
        <div class="search-section">
          <el-input
              v-model="searchQuery"
              placeholder="搜索视频、UP主、番剧..."
              size="large"
              class="search-input"
          >
            <template #append>
              <el-button type="primary" @click="handleSearch">
                <el-icon><Search /></el-icon>
                搜索
              </el-button>
            </template>
          </el-input>
        </div>
      </div>
    </div>

    <!-- 底部信息 -->
    <div class="footer-info">
      <p>如需帮助，请联系客服或查看<a href="/help">帮助中心</a></p>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import {
  HomeFilled,
  ArrowLeft,
  Refresh,
  Search,
  House,
  Fire,
  Promotion,
  Menu
} from '@element-plus/icons-vue'

const router = useRouter()
const searchQuery = ref('')

// 返回首页
const goHome = () => {
  router.push('/')
}

// 返回上一页
const goBack = () => {
  router.go(-1)
}

// 刷新页面
const refreshPage = () => {
  window.location.reload()
}

// 处理搜索
const handleSearch = () => {
  if (searchQuery.value.trim()) {
    router.push({
      path: '/search',
      query: { keyword: searchQuery.value }
    })
  }
}
</script>

<style scoped>
.bilibili-not-found {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

/* 背景装饰元素 */
.decoration-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.floating-element {
  position: absolute;
  font-size: 24px;
  opacity: 0.1;
  animation: float 6s ease-in-out infinite;
}

.element-1 { top: 10%; left: 5%; animation-delay: 0s; }
.element-2 { top: 20%; right: 10%; animation-delay: 1.5s; }
.element-3 { bottom: 30%; left: 15%; animation-delay: 3s; }
.element-4 { bottom: 15%; right: 5%; animation-delay: 4.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

/* 主要内容容器 */
.not-found-container {
  background: white;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  max-width: 800px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 2;
}

/* 错误动画区域 */
.error-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 30px;
  gap: 20px;
}

.error-number {
  font-size: 120px;
  font-weight: 900;
  color: #00a1d6;
  text-shadow: 3px 3px 0 rgba(0, 161, 214, 0.2);
  animation: bounce 2s ease-in-out infinite;
}

.error-number:nth-child(1) { animation-delay: 0.1s; }
.error-number:nth-child(3) { animation-delay: 0.2s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}

/* 损坏的电视插图 */
.error-illustration {
  position: relative;
}

.broken-tv {
  width: 120px;
  height: 100px;
  position: relative;
}

.tv-screen {
  width: 100px;
  height: 70px;
  background: #1a1a1a;
  border-radius: 8px;
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  border: 3px solid #333;
}

.static-effect {
  width: 100%;
  height: 100%;
  background:
      radial-gradient(circle at 30% 30%, #00a1d6 2px, transparent 3px),
      radial-gradient(circle at 70% 70%, #ff6b6b 2px, transparent 3px);
  animation: static 0.5s linear infinite;
  opacity: 0.3;
}

@keyframes static {
  0% { transform: translate(0, 0); }
  100% { transform: translate(5px, 5px); }
}

.tv-stand {
  width: 40px;
  height: 10px;
  background: #666;
  border-radius: 2px;
  margin: 0 auto;
}

/* 错误内容 */
.error-content {
  margin-bottom: 30px;
}

.error-title {
  font-size: 32px;
  font-weight: 700;
  color: #18191c;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #00a1d6, #4ecdc4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.error-description {
  font-size: 18px;
  color: #61666d;
  line-height: 1.6;
  margin-bottom: 24px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* 可能的原因 */
.possible-reasons {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin: 24px 0;
  text-align: left;
}

.possible-reasons h3 {
  color: #18191c;
  margin-bottom: 12px;
  font-size: 16px;
}

.possible-reasons ul {
  color: #61666d;
  padding-left: 20px;
  margin: 0;
}

.possible-reasons li {
  margin-bottom: 8px;
  line-height: 1.5;
}

/* 操作按钮 */
.action-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 30px 0;
}

.primary-btn {
  background: linear-gradient(135deg, #00a1d6, #0091c6);
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 161, 214, 0.3);
}

.secondary-btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
}

.refresh-btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
}

/* 快速导航 */
.quick-nav {
  margin: 30px 0;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.quick-nav h3 {
  color: #18191c;
  margin-bottom: 16px;
  font-size: 16px;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: white;
  border-radius: 6px;
  text-decoration: none;
  color: #61666d;
  transition: all 0.3s ease;
  border: 1px solid #e0e0e0;
  font-size: 14px;
}

.nav-link:hover {
  color: #00a1d6;
  border-color: #00a1d6;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 搜索区域 */
.search-section {
  max-width: 400px;
  margin: 30px auto 0;
}

.search-input {
  border-radius: 8px;
  overflow: hidden;
}

.search-input :deep(.el-input-group__append) {
  background: #00a1d6;
  border: none;
  color: white;
}

/* 底部信息 */
.footer-info {
  margin-top: 30px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.footer-info a {
  color: #00a1d6;
  text-decoration: none;
}

.footer-info a:hover {
  text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .bilibili-not-found {
    padding: 20px 16px;
  }

  .not-found-container {
    padding: 30px 20px;
  }

  .error-animation {
    flex-direction: column;
    gap: 10px;
  }

  .error-number {
    font-size: 80px;
  }

  .broken-tv {
    transform: scale(0.8);
  }

  .error-title {
    font-size: 24px;
  }

  .error-description {
    font-size: 16px;
  }

  .action-buttons {
    flex-direction: column;
    align-items: center;
  }

  .action-buttons .el-button {
    width: 100%;
    max-width: 280px;
  }

  .nav-links {
    gap: 10px;
  }

  .nav-link {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .error-number {
    font-size: 60px;
  }

  .not-found-container {
    padding: 20px 16px;
  }

  .error-title {
    font-size: 20px;
  }

  .error-description {
    font-size: 14px;
  }

  .nav-links {
    flex-direction: column;
  }
}
</style>